
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[EBAS_FAKTURA_DETALJE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[EBAS_FAKTURA_DETALJE]
GO

CREATE TABLE [dbo].[EBAS_FAKTURA_DETALJE] (
	[GUID] [uniqueidentifier] ROWGUIDCOL NOT NULL ,
	[MODTAGELSE_DATO] [datetime] NULL ,
	[FAKTURA_DATO] [datetime] NULL ,
	[BETALING_DATO] [datetime] NULL ,
	[FAKTURA_TYPE_GUID] [uniqueidentifier] NOT NULL ,
	[STUDERENDE_GUID] [uniqueidentifier] NOT NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[EBAS_FAKTURA_DETALJE] WITH NOCHECK ADD 
	CONSTRAINT [PK_EBAS_FAKTURA_DETALJE] PRIMARY KEY  CLUSTERED 
	(
		[GUID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[EBAS_FAKTURA_DETALJE] ADD 
	CONSTRAINT [FK_EBAS_FAKTURA_DETALJE_EBAS_FAKTURA_TYPE] FOREIGN KEY 
	(
		[FAKTURA_TYPE_GUID]
	) REFERENCES [dbo].[EBAS_FAKTURA_TYPE] (
		[GUID]
	),
	CONSTRAINT [FK_EBAS_FAKTURA_DETALJE_EBAS_STUDERENDE] FOREIGN KEY 
	(
		[STUDERENDE_GUID]
	) REFERENCES [dbo].[EBAS_STUDERENDE] (
		[GUID]
	)
GO
